<template>
  <div class="modifylocation-page">
    <div class="modifylocation-input">
      <div>相对屏幕左侧偏移量</div>
      <input type="number" v-on:change="e => handleXChange(e.target.value)"/>
    </div>
    <div class="modifylocation-input">
      <div>相对屏幕顶端偏移量</div>
      <input type="number" v-on:change="e => handleYChange(e.target.value)"/>
    </div>
    <div class="modifylocation-button">
      <button v-on:click="submitNewLocation">Submit</button>
    </div>
  </div>
</template>

<script>
var electron = ''
if (window.require) {
  electron = window.require('electron')
}

export default {
  name: 'ModifyLocation',
  data () {
    return {
      x: 0,
      y: 0
    }
  },
  methods: {
    submitNewLocation () {
      electron.ipcRenderer.send('change-player-location', { x: this.x, y: this.y })
    },
    handleXChange (newValue) {
      console.log(newValue)
      this.x = newValue
    },
    handleYChange (newValue) {
      console.log(newValue)
      this.y = newValue
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.modifylocation-page {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.modifylocation-input {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-content: center;
  margin-bottom: 5%;
}
.modifylocation-input div {
  margin-right: 5%;
}
.modifylocation-button {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-content: center;
  margin-top: 3%;
}
.modifylocation-button button {
  width: 20%;
}
</style>
